package com.fjec.market.schedule.handler;

import com.fjec.market.entity.InfoYsepayRegister;
import com.fjec.market.mapper.InfoYsepayRegisterMapper;
import com.fjec.market.rabbitmq.provider.YsRegisterResultQueryProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
@Slf4j
public class YsRegisterResultQueryHandler {

    @Resource
    private InfoYsepayRegisterMapper infoYsepayRegisterMapper;

    @Autowired
    private YsRegisterResultQueryProvider ysRegisterResultQueryProvider;

    public String handle(int limit, int minutes) {
        List<InfoYsepayRegister> infoYsepayRegisters = infoYsepayRegisterMapper.getRegisteringNoResult(limit, minutes);

        infoYsepayRegisters.forEach(reg -> ysRegisterResultQueryProvider.sendYsRegisterResultQuery(reg.getId()));

        return "success";
    }
}
